import 'dart:io';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

class LoginPage extends StatefulWidget {
  @override
  _LoginPageState createState() => _LoginPageState();
}

class _LoginPageState extends State<LoginPage> {
  //生成下拉框
  List<DropdownMenuItem> generateItemList() {
    List<DropdownMenuItem> items = new List();
    DropdownMenuItem item1 =
        new DropdownMenuItem(value: '+86', child: new Text('+86 中国'));
    items.add(item1);
    return items;
  }

  @override
  void initState() {
    // 沉浸式开始
    if (Platform.isAndroid) {
      SystemUiOverlayStyle systemUiOverlayStyle =
          SystemUiOverlayStyle(statusBarColor: Colors.transparent);
      SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
    }
    // 结束
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    //下拉菜单item点击之后获取到的值
    var selectItemValue;
    return Scaffold(
        appBar: AppBar(
          backgroundColor: Colors.transparent,
          elevation: 0,
        ),
        body: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            SizedBox(height: 10),
            Text("  请输入手机号码",
                style: TextStyle(
                    fontWeight: FontWeight.bold,
                    letterSpacing: 1,
                    fontSize: 30,
                    color: Color(0xFF333333))),
            SizedBox(height: 10),
            Text(" 为方便进行联系，请您输入您的常用手机号码",
                style: TextStyle(
                    letterSpacing: 1, fontSize: 18, color: Color(0xFF999999))),
            Padding(
              padding: EdgeInsets.symmetric(horizontal: 8),
              child: Row(
                children: [
                  DropdownButton(
                      // 隐藏下划线
                      underline: Container(height: 0),
                      //设置默认值
                      value: '+86',
                      items: generateItemList(),
                      onChanged: (v) => {
                            setState(() {
                              selectItemValue = v;
                            })
                          }),
                  Expanded(
                      child: TextField(
                    decoration: InputDecoration(border: InputBorder.none),
                  ))
                ],
              ),
            ),
            Divider(
              color: Colors.black,
            ),
            SizedBox(
              height: 10,
            ),
            GestureDetector(
              onTap: () => {},
              child: Text(
                "  手机已经不在使用>",
                style: TextStyle(color: Color(0xff333333), fontSize: 14),
              ),
            ),
            SizedBox(
              height: 10,
            ),
            SizedBox(
                height: 50,
                width: double.infinity,
                child: Padding(
                  padding: const EdgeInsets.symmetric(horizontal: 6.0),
                  child: RaisedButton(
                    color: Colors.black,
                    //不设置函数 颜色无效
                    onPressed: () => {},
                    child: Text(
                      "下一步",
                      style: TextStyle(color: Colors.white, fontSize: 20),
                    ),
                  ),
                )),
            SizedBox(
              height: 50,
            ),
            Row(children: <Widget>[
              Expanded(child: Divider()),
              Text(
                "其他登录方式",
                style: TextStyle(
                    color: Color(
                      0xff999999,
                    ),
                    fontSize: 16),
              ),
              Expanded(child: Divider()),
            ]),
            SizedBox(
              height: 30,
            ),
            Center(
              child: Image.network(
                "https://www.easyicon.net/api/resizeApi.php?id=1230528&size=96",
                width: 80,
                height: 80,
              ),
            )
          ],
        ));
  }
}
